package lagou.MapTest.ListTest;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

public class TreeSetTest {
    public static void main(String[] args) {
        Comparator<Student> c1 = new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge() - o2.getAge();
            }
        };
        Set<String> s1 = new TreeSet<>();
        s1.add("1");
        System.out.println(s1);
        s1.add("2");
        s1.add("3");
        Set<Student> stu1 = new TreeSet<>(c1);
        stu1.add(new Student("yankun",18));
        stu1.add(new Student("yankun2",19));
        stu1.add(new Student("yankun3",20));
        System.out.println(stu1);//默认从小到大

    }
}
